package com.report.reportserver.config;

import com.report.reportserver.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @ ClassName: ConfigInterceptor
 * @ Description：配置拦截器
 * @ Modified By：
 * @ Version:
 * @ Author     ：LiYing
 * @ Date       ：Created in 18:53 2022/3/10
 */

@Configuration//配置注解
public class ConfigInterceptor implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //定义要拦截的路径
        String[] addPathPatterns = {
                "/user/**"//user下的所有路径
        };
        //定义不拦截的路径
        String[] excludePathPatterns = {
                "/user/error"
        };

        registry.addInterceptor(new LoginInterceptor()).addPathPatterns(addPathPatterns).excludePathPatterns(excludePathPatterns);

        //registry.addInterceptor(new AccessInterceptor()).addPathPatterns("/add").excludePathPatterns("/update");
    }
}
